package com.pan.concurrency.thread;

/**
 * <p>
 *    多线程
 * </p>
 *
 * @author kaiji
 * @since 2020/1/14 16:05
 */
public class ThreadTest1 {

    public static void main(String[] args) {
        MyRunner runner = new MyRunner();
        Thread t1 = new Thread(runner);
        Thread t2 = new Thread(runner);
        t1.setName("线程A");
        // 设置抢占权重 1-10 默认5
        t1.setPriority(Thread.MAX_PRIORITY);
        t2.setName("线程B");
        t1.start();
        t2.start();
    }

}
class MyRunner implements Runnable {
    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            System.out.println(Thread.currentThread().getName() + " i = "  + i);
        }
    }
}
